class Dial {
  float x, y; // X-coordinate, y-coordinate
  float r; // defines the radius
  float a; // Used to define the pointer angle
  String t; // title of the dial
  float s; // scale for data vs radius

  // Constructor
  Dial(float xpos, float ypos, float rad, String title) {
    x = xpos;
    y = ypos;
    r = rad;
    a = 0.0;
    t = title;
  }

  void setScale(float sc) {
    s = sc;
  }

  void display(float d1, float d2) {
    fill(255);
    ellipse(x, y, radius, radius);
    fill(0);
    textFont(f, 24);
    textAlign(CENTER);
    text(t, x, y + 20 + radius/2);

    float x1 = 0;
    float y1 = 0;
    float hyp, opp, adj;

    float a = atan2(d1, d2);
  
    opp = d2 / s; // scale down the values
    adj = d1 / s;

    hyp = sqrt(pow(opp,2) + pow(adj,2));
    hyp *= r/2;

    x1 = x + hyp * cos(a);
    y1 = y + hyp * sin(a);

    line(x, y, x1, y1);
  }
}
